pub fn new_birthday_probability(n: u32) -> f64 {
    if n < 2 {
        return 0.0;
    }

    let mut probability = 1.0;
    for i in 0..n {
        probability *= (365 - i) as f64 / 365.0;
    }

    (1.0 - probability).round_to(4)
}

trait RoundTo {
    fn round_to(self, decimals: u32) -> Self;
}

impl RoundTo for f64 {
    fn round_to(self, decimals: u32) -> Self {
        let factor = 10f64.powi(decimals as i32);
        (self * factor).round() / factor
    }
}
